package com.verlet.web.fegin;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 比fallback 多了异常信息
 * @author verlet
 */
@Component
public class NacosFeignServiceFallbackFactory implements FallbackFactory<NacosFeignService> {

    /**
     * @param throwable feign在调用过程中产生异常
     * @return
     */
    @Override
    public NacosFeignService create(Throwable throwable) {
        return new NacosFeignService() {
            @Override
            public String getNacosApplicationName() {
                throwable.printStackTrace();
                return "熔断了。。、";
            }

            @Override
            public String getConfig() {
                throwable.printStackTrace();
                return "熔断了。。、";
            }
        };
    }
}
